<?php 


	$path = Yii::getPathOfAlias('ext.xheditor.source');	
	
	$path = Yii::app()->getAssetManager()->publish($path);

	$html = <<<HTML
	<div id="comment-panel"><ul><li><a href="#tabs-1">tabs-1</a></li><li><a href="#tabs-2">tabs-2</a></li></ul><div id="tabs-1">dddkkdk</div><div id="tabs-2">tabs-2</div></div>
HTML;
	$time = time();
	
	
	$plugin = <<<PLUGIN
	    // 文本编辑器的自定义插件
    var coderPlugin = {
        Code:{c:'xheBtnLang',t:'插入代码',h:1,e:function(){
            var _this=this;
            var htmlCode='<div><select id="xheCodeType"><option value="html">HTML/XML</option><option value="js">Javascript</option><option value="css">CSS</option><option value="php">PHP</option><option value="java">Java</option><option value="py">Python</option><option value="pl">Perl</option><option value="rb">Ruby</option><option value="csharp">C#</option><option value="c">C++/C</option><option value="vb">VB/ASP</option><option value="as3">Action Script</option><option value="shell">Bash</option><option value="coldfusion">ColdFusion</option><option value="delphi">Delphi</option><option value="diff">Diff</option><option value="erlang">Erlang</option><option value="groovy">Groovy</option><option value="javafx">JavaFX</option><option value="plain">Plain</option><option value="powershell">PowerShell</option><option value="sql">SQL</option><option value="scala">Scala</option><option value="sass">Sass</option><option value="">其它</option></select></div><div><textarea id="xheCodeValue" wrap="soft" spellcheck="false" style="width:300px;height:100px;" /></div><div style="text-align:right;"><input type="button" id="xheSave" value="确定" /></div>';           
            var jCode=$(htmlCode),jType=$('#xheCodeType',jCode),jValue=$('#xheCodeValue',jCode),jSave=$('#xheSave',jCode);
            jSave.click(function(){ 
                var inputCode = jValue.val();
                inputCode = "<div style='border:solid #ccc 1px;width:98%;overflow:auto;'>"
                + "<div style='background-color:#ddd; border-bottom:solid 1px #ccc; line-height:1.5em; text-indent:0.5em;'>" + $("#xheCodeType").val() + "代码</div>"
                + '<pre class=brush:'+jType.val()+';>'
                + inputCode.replace(/</g, "<").replace(/>/g, ">")
                + "</pre>"
                + "</div>";
 
                _this.loadBookmark();
 
                _this.pasteHTML(inputCode);
                _this.hidePanel();
                return false;
            });
            _this.showDialog(jCode);
        }},        
        map:{c:'btnMap',t:'插入Google地图',e:function(){
			var _this=this;
			_this.showIframeModal('Google 地图','{$path}/xheditor_plugins/googlemap/googlemap.php',function(v){_this.pasteHTML('<img src="'+v+'" />');},538,404);
		}},
		Flv:{c:'btnFlv',t:'插入Flv视频',h:1,e:function(){
			var _this=this;
			var FlvhtmlCode= '<div>Flv地址:<input type="text" id="FlvUrl" /></div><div>宽度高度：<input type="text" id="FlvHeight" value="400" style="width:40px;" /> x <input type="text" id="FlvWidth" value="480" style="width:40px;" /></div><div><input type="button" id="FlvSave" value="增加" />';
			var FlvCode = $(FlvhtmlCode);
			var FlvValue = $('#FlvUrl',FlvCode);
			var FlvHeight = $('#FlvHeight',FlvCode);
			var FlvWidth = $('#FlvWidth',FlvCode);
			
			var FlvSave = $('#FlvSave',FlvCode);
			FlvSave.click(function(){
				var FlvMediaCode = FlvValue.val();
				FlvMediaCode = '<embed id="fInspectorSwf_{$time}" height="'+FlvHeight.val()+'" width="'+FlvWidth.val()+'" flashvars="file='+FlvMediaCode+'" bgcolor="#ffffff" quality="high" allowfullscreen="true" allowscriptaccess="always" wmode="transparent" src="{$path}/xheditor_plugins/mediaplayer/player.swf" type="application/x-shockwave-flash">';
				
				_this.loadBookmark();
                _this.pasteHTML(FlvMediaCode);
                _this.hidePanel();
                return false;
			});
			_this.showDialog(FlvCode);
		}},
    }; 
PLUGIN;
?>


<?php Yii::app()->getClientScript()->registerScript('news-form-editor-heade',$plugin,CClientScript::POS_HEAD);?>
<script language="javascript" type="text/javascript">
    $(function(){
        $(".xheLayout").width("600px");
        
    });
</script>
<style>
<!--
.btnMap{
	background:url('<?php echo $path;?>/xheditor_plugins/googlemap/map.gif') no-repeat;
	width:20px;
	height:20px;
}
.btnFlv{
	background:url('<?php echo $path;?>/xheditor_plugins/mediaplayer/flv.gif') no-repeat;
	width:20px;
	height:20px;
}   

-->
</style>


<div class="form">    
   <div class="row">
    	<?php echo $form->textField($model,'arc_title',array('size'=>60,'maxlength'=>200)); ?>
    	<?php echo $form->error($model,'arc_title'); ?>
    </div>
</div>

<div style="-moz-border-radius: 2px\9;">
    <div class="form">
    	<div class="row">
    		<?php //echo $form->textArea($model,'arc_content',array('rows'=>6, 'cols'=>50)); ?>
    		<?php $this->widget('ext.xheditor.JXHEditor', array(
    		    'model' => $model,
    		    'attribute' => 'arc_content',
    			'language'=>'zh_cn',
    //		    'htmlOptions'=>array('cols'=>80,'rows'=>20),
    			'options'=>"{plugins:coderPlugin,tools:'full',skin:'o2007blue',height:'300',urlBase:'/',urlType:'root',showBlocktag:true,internalScript:false,internalStyle:false,loadCSS:'http://xheditor.com/test.css',fullscreen:false,sourceMode:false,forcePtag:true,upLinkUrl:'{$this->createUrl('file/editorupload',array('type'=>Category::CATEGORY_NEWS,'uid'=>Yii::app()->user->id))}',upLinkExt:'rar,zip',upImgUrl:'{$this->createUrl('file/editorupload',array('type'=>Category::CATEGORY_NEWS,'uid'=>Yii::app()->user->id))}',upImgExt:'jpg,jpeg,gif,png',upFlashUrl:'{$this->createUrl('file/editorupload',array('type'=>Category::CATEGORY_NEWS,'uid'=>Yii::app()->user->id))}',upFlashExt:'swf',upMediaUrl:'{$this->createUrl('file/editorupload',array('type'=>Category::CATEGORY_NEWS,'uid'=>Yii::app()->user->id))}',upMediaExt:'wmv,avi,wma,mp3,mid'}"
    		));?>
    		<?php echo $form->error($model,'arc_content'); ?>
    	</div>
    </div><!-- form -->
</div>

